﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GBlog.Core.Entities;

namespace GBlog.Core.Mapping
{
    public class TagMap : MapBase<Tag, int>
    {
        public TagMap()
        {
            ToTable("Core_Tag");
            RegisterID();
            Property(t => t.Name).IsRequired().HasMaxLength(32);
            Property(t => t.Seo).IsRequired().HasMaxLength(64);

            HasMany(t => t.Posts).WithMany(t => t.Tags).Map(x =>
            {
                x.ToTable("Core_PostTag");
                x.MapLeftKey("TagID");
                x.MapRightKey("PostID");
            });
            RegisterDefault();
        }
    }
}
